﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Roton2.TextModeEmulation
{
    public struct AnsiChar
    {
        /// <summary>
        /// Index of the glyph in the font.
        /// </summary>
        public byte Character;

        /// <summary>
        /// Foreground and background color of the glyph.
        /// </summary>
        public byte Color;

        /// <summary>
        /// Create an AnsiChar from raw data.
        /// </summary>
        public AnsiChar(Int16 data)
        {
            this.Character = (byte)(data & 0xFF);
            this.Color = (byte)((data >> 8) & 0xFF);
        }

        /// <summary>
        /// Create an AnsiChar with the given character index and color.
        /// </summary>
        public AnsiChar(int character, int color)
        {
            this.Character = (byte)(character & 0xFF);
            this.Color = (byte)(color & 0xFF);
        }

        /// <summary>
        /// Convert an AnsiChar to raw data.
        /// </summary>
        public Int16 ToInt16()
        {
            return (Int16)(((int)Color << 8) | Character);
        }
    }
}
